package com.yu.crm.web;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yu.crm.domain.request.LogReq;
import com.yu.crm.domain.response.LogRes;
import com.yu.crm.service.impl.PubUserActionLogService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import springfox.documentation.annotations.ApiIgnore;

@RestController
@RequestMapping("/pub-log")
@Api(value = "日志记录",tags = {"日志记录"})
public class PubLogController {
    @Autowired
    PubUserActionLogService pubUserActionLogService;

    /**
     * 日志详情
     */
    @GetMapping("log-detail")
    @ApiOperation(value = "日志详情")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "size", value = "每页大小"),
            @ApiImplicitParam(name = "current", value = "当前页"),
            @ApiImplicitParam(name = "appName", value = "应用名"),
            @ApiImplicitParam(name = "fileName", value = "文件名")
    })
    public IPage<String> appLogDetail(@ApiIgnore Page<String> page, String appName, String fileName) {
        return pubUserActionLogService.appLogDetail(page,appName,fileName);
    }

    /**
     * 日志列表
     * @param req
     */
    @GetMapping("log-list")
    @ApiOperation(value = "日志列表")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "size", value = "每页大小"),
            @ApiImplicitParam(name = "current", value = "当前页")
    })
    public IPage<LogRes> appLogList(@ApiIgnore Page<LogRes> page, LogReq req) {
        return pubUserActionLogService.appLogList(page,req);
    }
}
